[#ftl]
[@define "agile.PseudoRuleEditor","agile.CssRuleEditor"]	
	metadataCategory:"parameters.pseudo"	
	,pseudoSelectorOptions:["::first-letter","::first-line","::hover","::before","::after"]
	,init:function(){
		this.inherited(arguments);
		style.set(this.pseudoSelectorNode,{display:"inline"});
		
		//override the onChange event handler
//		var self = this;
//		self.htmlName = this.pseudoSelectorOptions[0];
//		self.name = this.pseudoSelectorOptions[0].replace(/:/g,"").replace(/-/g,"_");
//		
		this.pseudoSelector.set("value","");
		this.pseudoSelector.watch("value",lang.hitch(this,function(name,old,value){
			this.htmlName = value;
			this.name = value.replace(/:/g,"").replace(/-/g,"_");			
			this.reset1("value",null);
		}));	
	}
	,onChange:function(value,name,htmlName){
		console.error(this.declaredClass,"[onChange] arguments=",arguments,"this._notWatchValue=",this._notWatchValue);
		
//		if(this.context && !this._notWatchValue){	
			var ownerWidget = this.context.getCurrentWidget();
			var pseudo = ownerWidget.metadata("parameters.pseudo");
			if(pseudo == undefined){
				var pseudoClass = "p" + (new Date().getTime());
				ownerWidget.metadata("pseudoClass",pseudoClass);
								
				pseudo = {};
				var nodes = ownerWidget.getStyleNodes();
				for(var i = nodes.length-1; i >=0; i--){
					domClass.add(nodes[i],pseudoClass);
				}
				ownerWidget.metadata("parameters.pseudo",pseudo);
			}
			pseudo[name] = value;				
			agile.replacePseudoRule("." + pseudoClass + htmlName,value);			
//		}		
		this._notWatchValue = false;
	}

 	,set:function(name,value){
		if(name == "value"){				
			var ownerWidget = this.context.getCurrentWidget();
			if(ownerWidget){
				arguments[1] = ownerWidget.metadata(this.metadataCategory+"."+this.name);				
			}
//			//console.log(this.declaredClass,"set",this.htmlName,arguments);
			this.inherited(arguments);
		}else{
			this.inherited(arguments);
		}
	}
 	,reset1:function(name,value){
		if(name == "value"){	
			var ownerWidget = this.context.getCurrentWidget();
			if(ownerWidget){
				arguments[1] = ownerWidget.metadata(this.metadataCategory+"."+this.name);				
			}
			console.log(this.declaredClass,"reset1",this.htmlName,arguments);
			this._notWatchValue = true;
			this.inherited(arguments);
		}else{
			this.inherited(arguments);
		}
	}
	,isValid:function(){
		return true;
	}
[/@]
